<?php defined('APP_PATH') or exit('Access Denied');?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>更新文档</title>
<link rel="stylesheet" type="text/css" href="vonuo/static/css/vonuo.css">
<script type="text/javascript" src="vonuo/static/js/jquery.min.js"></script>
<script type="text/javascript" src="vonuo/static/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="comm/KEditor/kindeditor.js"></script>
<script type="text/javascript" src="comm/KEditor/lang/zh_CN.js"></script>
<script type="text/javascript">
//编辑器
KindEditor.ready(function(K){
	K.create('textarea[name="content"]', {
		themeType : 'simple',
		resizeType : 1,
		uploadJson : 'comm/KEditor/upload_json.php',
		fileManagerJson : 'comm/KEditor/file_manager_json.php',
		allowFileManager : true,
		afterBlur: function(){this.sync();}
	});
});
//上传框编号
var formNum = 3;
//打开弹窗
function selectPic(formNum,needThumb,callThumb){
	var upurl = '/admin.php?c=upld&a=img&needthumb='+needThumb+'&callthumb='+callThumb+'&formnum='+formNum+'&random='+Math.random();
	$("#zhezhao").css('width',$(document).width());
	$("#zhezhao").css('height',$(document).height());
	$("iframe#upimgframe").attr('src', upurl);
	$("#zhezhao").show();
	$("#uppic").show();
}
//关闭弹窗
function cancelSel(){
	$("#uppic").hide();
	$("#zhezhao").hide();
}
//添加上传框
function addForm(){
	var upformtpl = '<tr id="tr_'+formNum+'"><td class="txt_right txt_s_blue" width="80">上传图片：</td><td><input name="album[]" id="slturl_'+formNum+'" type="text" readonly class="blue_input input_w_175 f_left" /><a href="javascript:;" onclick="selectPic('+formNum+',\'no\',\'no\');" class="btn_wei f_left">浏览</a><a href="javascript:;" onclick="cancelForm('+formNum+');" class="btn_wei f_left">删除</a></td></tr>';
	$("#upformpos").append(upformtpl);
	formNum++;
}
//删除上传框
function cancelForm(formNum){
	if($("#slturl_"+formNum).val() != ''){
		if(confirm('确定删除？')){
			$("tr").remove("#tr_"+formNum);
		}
	}else{
		$("tr").remove("#tr_"+formNum);
	}
}
//上传成功后调用
function upsuc(formNum, saveUrl){
	$("#slturl_"+formNum).val(saveUrl);
	$("#uppic").hide();
	$("#zhezhao").hide();
}
//删除相册图片
function delPic(picId){
	if(false == confirm('确定删除？')){
		return false;
	}
	var url = "admin.php?c=zzcon&a=delpic";
	$.post(url, {id:picId},function(result){
		if(result == '1'){
			$("li#zzpic_"+picId).remove();
		}else{
			alert('删除图片失败！');
		}
	});
}
function check(){
	if($.trim($("input[name='title']").val()) == ''){
		$("#need_title").html("<strong style='color:red;'>请输入文档标题！</strong>");
		$("input[name='title']").focus();
		return false;
	}else{
		$("#need_title").html("<strong style='color:red;'>√</strong>");
	}
	return true;
}
</script>
</head>

<body>
<div class="gs_wraper gs_p_l0">
	<div class="title">
		<a href="<?php echo spUrl('zzcat','lis');?>">栏目列表</a>
		<a href="javascript:;" class="hover">更新文档</a>
	</div>
	<form action="<?php echo spUrl('zzcon','doupd',array('id'=>$zzcon['id'],'cid'=>$cid));?>" method="post">
	<div class="tab_box" style="margin-bottom:10px;">
		<table border="0" cellspacing="0" cellpadding="0" class="table_btm">
			<tr>
				<td class="txt_right txt_s_blue" width="80">文档标题：</td>
				<td>
					<input name="title" value="<?php echo $zzcon['title'];?>" type="text" class="blue_input input_w_175" />
					<span id="need_title"></span>
				</td>
			</tr>
			<tr>
				<td class="txt_right txt_s_blue">所属栏目：</td>
				<td>
					<select name="cid" class="blue_input input_w_175 f_left" disabled>
					<?php foreach($zzcat as $row){?><option value="<?php echo $row['id'];?>" <?php if($row['id'] == $zzcon['cid']){?>selected<?php }?>><?php echo $row['format'];?></option><?php }?>
					</select>
					<span id="need_cid" style="margin-left:8px;"></span>
				</td>
			</tr>
			<tr>
				<td class="txt_right txt_s_blue">文档属性：</td>
				<td>
					<input name="visible" type="checkbox" value="1" <?php if($zzcon['visible']){?>checked="checked"<?php }?> class="m_lr_5"/><label>可见</label>
					<input name="stick" type="checkbox" value="1" <?php if($zzcon['stick']){?>checked="checked"<?php }?> class="m_lr_5"/><label>置顶</label>
					<input name="mkhtml" type="checkbox" value="1" <?php if($zzcon['mkhtml']){?>checked="checked"<?php }?> class="m_lr_5"/><label>生成静态</label>
				</td>
			</tr>
			<tr>
				<td class="txt_right txt_s_blue">浏览次数：</td>
				<td><input name="views" value="<?php echo $zzcon['views'];?>" type="text" class="blue_input input_w_175" /></td>
			</tr>
			<tr>
				<td class="txt_right txt_s_blue">指定排序：</td>
				<td><input name="odnum" value="<?php echo $zzcon['odnum'];?>" type="text" class="blue_input input_w_175" /></td>
			</tr>
			<tr>
				<td class="txt_right txt_s_blue">略缩图：</td>
				<td>
					<input name="thumb" id="slturl_1" value="<?php echo $zzcon['thumb'];?>" type="text" readonly class="blue_input input_w_175 f_left" />
					<a href="javascript:;" onclick="selectPic(1,'yes','yes');" class="btn_wei f_left">浏览</a>
				</td>
			</tr>
			<div id="type_1_7"><?php foreach($type_1_7 as $row){ echo $row;}?></div>
			<tr>
				<td class="txt_right txt_s_blue">关键词：</td>
				<td><input name="keywords" value="<?php echo $zzcon['keywords'];?>" type="text" class="blue_input input_w_250 f_left"  /></td>
			</tr>
			<tr>
				<td class="txt_right txt_s_blue" valign="top">描述信息：</td>
				<td><textarea name="description" cols="60" rows="5" class="blue_textarea"><?php echo $zzcon['description'];?></textarea></td>
			</tr>
			<div id="type_8"><?php foreach($type_8 as $row){ echo $row;}?></div>
		</table>
		<ul class="ppiclist"  style="margin-left:80px;">
		<?php foreach($zzpic as $v){?>
			<li id="zzpic_<?php echo $v['id']?>">
				<a href="javascript:;" title="删除" onclick="delPic(<?php echo $v['id'];?>);" class="f_right f_14 f_weight closeBtn">×</a>
				<a href="/<?php echo $v['photo'];?>" target="_blank"><img src="/<?php echo $v['thumb'];?>" /></a>
			</li>
		<?php }?>
		</ul>
		<div class="ppicupfm">
		<table border="0" cellspacing="0" cellpadding="0" class="table_btm">
			<tr>
				<td class="txt_right txt_s_blue" width="80">上传图片：</td>
				<td>
					<input name="album[]" id="slturl_2" type="text" readonly class="blue_input input_w_175 f_left" />
					<a href="javascript:;" onclick="selectPic(2,'no','no');" class="btn_wei f_left">浏览</a>
					<a href="javascript:;" onclick="addForm();" class="btn_wei f_left" style="color:red;">添加</a>
				</td>
			</tr>
		</table>
		<table id="upformpos" border="0" cellspacing="0" cellpadding="0" class="table_btm"></table>
		</div>
		<table border="0" cellspacing="0" cellpadding="0" class="table_btm">
			<div id="type_9_10"><?php foreach($type_9_10 as $row){ echo $row;}?></div>
			<tr>
				<td class="txt_right txt_s_blue" valign="top" width="80">详细内容：</td>
				<td><textarea name="content" style="width:700px;height:350px;visibility:hidden;"><?php echo $zzcon['content'];?></textarea></td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td><a href="javascript:;" onclick="if(check()){$('form').submit();}" class="sure_submit f_left time">确 定</a><a href="<?php echo spUrl('zzcon','lis',array('cid'=>$cid));?>" class="return_btn f_left">返 回</a></td>
			</tr>
		</table>
	</div>
	</form>
<!-- 上传图片 -->
<div id="uppic" style="position:fixed;left:400px;top:180px;z-index:999;display:none;">
	<a href="javascript:;" onclick="cancelSel();" title="关闭" class="f_right f_14 f_weight closeBtn">×</a>
	<iframe id="upimgframe" src="" width="325" height="130" frameborder="no" scrolling="no"></iframe>
</div>
<div id="zhezhao" class="zhezhao"></div>
</div>
</body>
</html>